home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / dev / c / cweb31p9d.lha / CWeb / comm-p.hch < prev    next >
Text File  |  1994-07-02  |  17KB  |  415 lines

  1.                                 -*-Web-*-
  2. This file, COMMON-P.HCH, is part of CWEB.
  3. It is a changefile for COMMON.H, Version 3.1.
  4.  
  5. Authors and Contributors:
  6. (H2B) Hans-Hermann Bode, Universität Osnabrück,
  7.   (hhbode@@dosuni1.rz.uni-osnabrueck.de or HHBODE@@DOSUNI1.BITNET).
  8.  
  9. (KG) Klaus Guntermann, TH Darmstadt,
  10.   (guntermann@@iti.informatik.th-darmstadt.de).
  11.  
  12. (AS) Andreas Scherer,
  13.   Abt-Wolf-Straße 17, 96215 Lichtenfels, Germany.
  14.  
  15. (CS) Carsten Steger, Universität München,
  16.   carsten.steger@@informatik.tu-muenchen.de
  17.  
  18. (TW) Tomas Willis
  19.   tomas@@cae.wisc.edu
  20.  
  21. Caveat utilitor:  Some of the source code introduced by this change file is
  22. made conditional to the use of specific compilers on specific systems.
  23. This applies to places marked with `#ifdef __TURBOC__' and `#ifdef _AMIGA'.
  24.  
  25. Run WMERGE with the masterfile COMMON.H and this changefile COMMON-P.HCH
  26. to produce COMMON-P.H needed in the MAKEFILEs.
  27.  
  28. This program is distributed WITHOUT ANY WARRANTY, express or implied.
  29.  
  30. The following copyright notice extends to this changefile only, not to the
  31. masterfile COMMON.H.
  32.  
  33. Copyright (C) 1993,1994 Andreas Scherer
  34. Copyright (C) 1991,1993 Carsten Steger
  35. Copyright (C) 1991-1993 Hans-Hermann Bode
  36.  
  37. Permission is granted to make and distribute verbatim copies of this
  38. document provided that the copyright notice and this permission notice
  39. are preserved on all copies.
  40.  
  41. Permission is granted to copy and distribute modified versions of this
  42. document under the conditions for verbatim copying, provided that the
  43. entire resulting derived work is distributed under the terms of a
  44. permission notice identical to this one.
  45.  
  46. Version history:
  47.  
  48. Version    Date        Author    Comment
  49. a1/t1    10 Oct 1991    H2B    First attempt for COMMON.H 2.0.
  50. p2    13 Feb 1992    H2B    Updated for COMMON.H 2.1, ANSI and Turbo
  51.                 changefiles merged together.
  52. p3    14 Apr 1992    H2B    Nothing changed but source and target names.
  53. p4    21 Jun 1992    H2B    Nothing changed.
  54. p5    18 Jul 1992    H2B    Extensions for C++ implemented.
  55. p5a    24 Jul 1992    KG    adaptions for other ANSI C compiler
  56. p5b    29 Jul 1992    H2B    Minor correction for |__TURBOC__|.
  57. p6    06 Sep 1992    H2B    |dot_dot_dot| added.
  58. p6a     15 Mar 1993     AS      adaptions for SAS/C 6.0
  59. p6b     28 Jul 1993     AS      new patch level due to minor changes
  60. p6c    04 Sep 1993    AS    new patch level due to major changes
  61. p6d    09 Oct 1993    AS    Updated for COMMON.H 2.8. (This was p7 for me)
  62. p7    13 Nov 1992    H2B    Converted to master change file, updated for
  63.                 common.h 2.8. [Not released.]
  64. p7.5    29 Nov 1992    H2B    Updated for common.h 2.9beta. [Not released.]
  65. p8    04 Dec 1992    H2B    Updated for common.h 2.9++ (stuff went into
  66.                 the source file). [Not released.]
  67. p8a    10 Mar 1993    H2B    Restructured for public release. [Not released.]
  68. p8b    15 Apr 1993    H2B    Updated for common.h 3.0beta. [Not released.]
  69. p8c    21 Jun 1993    H2B    Updated for final common.h 3.0.
  70. p8d    25 Oct 1993    AS    Incorporated with Amiga version 2.8 [p7] and
  71.                 updated to version 3.0.
  72. p8e    04 Nov 1993    AS    Minor bugs fixed for UNIX and GNU-C.
  73. p9    18 Nov 1993    AS    New patch level for CWEB 3.1.
  74. p9a    30 Nov 1993    AS    Minor changes and corrections.
  75. p9b    06 Dec 1993    AS    Multilinguality implemented.
  76.     07 Dec 1993    AS    Fixed an obvious portability problem.
  77. p9c    18 Jan 1994    AS    Version information included.
  78. p9d    13 May 1994    AS    Dynamic memory allocation.
  79.     24 Jun 1994    AS    ARexx support for error-handling.
  80.     02 Jul 1994    AS    Portability version.
  81. ------------------------------------------------------------------------------
  82. @x l.1
  83. % This file is part of CWEB.
  84. % This program by Silvio Levy and Donald E. Knuth
  85. % is based on a program by Knuth.
  86. % It is distributed WITHOUT ANY WARRANTY, express or implied.
  87. % Version 3.0 --- June 1993
  88. @y
  89. % This file, common.h, is part of CWEB.
  90. % This program by Silvio Levy and Donald E. Knuth
  91. % is based on a program by Knuth.
  92. % It is distributed WITHOUT ANY WARRANTY, express or implied.
  93. % Version 2.1 -- Don Knuth, January 1992
  94. % Version 2.1 [p5] --- Hans-Hermann Bode, July 1992
  95. % Version 2.1 [p5a] --- Klaus Guntermann, July 1992
  96. % Version 2.1 [p5b] --- Hans-Hermann Bode, July 1992
  97. % Version 2.1 [p6] --- Hans-Hermann Bode, September 1992
  98. % Version 2.1 [p6a] --- Andreas Scherer, March 1993
  99. % Version 2.1 [p6b] --- Andreas Scherer, July 1993
  100. % Version 2.1 [p6c] --- Andreas Scherer, September 1993
  101. % Version 2.8 --- Don Knuth, September 1992
  102. % Version 2.8 [p7] --- Andreas Scherer, October 1993
  103. % Version 3.0 --- Don Knuth, June 1993
  104. % Version 3.0 [p8c] --- Hans-Hermann Bode, June 1993
  105. % Version 3.0 [p8d] --- Andreas Scherer, October 1993
  106. % Version 3.0 [p8e] --- Andreas Scherer, November 1993
  107. % Version 3.1 [p9] --- Andreas Scherer, November 1993
  108. % Version 3.1 [p9a] --- Andreas Scherer, November 1993
  109. % Version 3.1 [p9b] --- Andreas Scherer, December 1993
  110. % Version 3.1 [p9c] --- Andreas Scherer, January 1994
  111. % Version 3.1 [p9d] --- Andreas Scherer, July 1994
  112. @z
  113. ------------------------------------------------------------------------------
  114. @x l.7
  115. % Copyright (C) 1987,1990,1993 Silvio Levy and Donald E. Knuth
  116. @y
  117. % Copyright (C) 1987,1990,1993 Silvio Levy and Donald E. Knuth
  118. % Copyright (C) 1991-1993 Hans-Hermann Bode
  119. % Copyright (C) 1991,1993 Carsten Steger
  120. % Copyright (C) 1993,1994 Andreas Scherer
  121. @z
  122. ------------------------------------------------------------------------------
  123. @x l.18
  124. % Please send comments, suggestions, etc. to levy@@geom.umn.edu.
  125. @y
  126. % Please send comments, suggestions, etc. to levy@@geom.umn.edu.
  127. % If related to changes specific for MSDOS, however,
  128. % send them to Hans-Hermann Bode,
  129. % hhbode@@dosuni1.rz.uni-osnabrueck.de or HHBODE@@DOSUNI1.BITNET.
  130. % If related to changes specific for AMIGA, however,
  131. % send them to Andreas Scherer,
  132. % Abt-Wolf-Straße 17, 96215 Lichtenfels, Germany.
  133. @z
  134. ------------------------------------------------------------------------------
  135. PORTABILITY
  136. @x l.24
  137. First comes general stuff:
  138.  
  139. @y
  140. First comes general stuff.
  141. In {\mc TURBO} \CEE/, we use |huge| pointers instead of large arrays.
  142. @^system dependencies@>
  143.  
  144. @f far int
  145. @f huge int
  146. @f HUGE int
  147. @#
  148. @z
  149. ------------------------------------------------------------------------------
  150. PORTABILITY, SYSTEM DEPENDENCIES
  151. @x l.33
  152. extern int phase; /* which phase are we in? */
  153. @y
  154. extern int phase; /* which phase are we in? */
  155. @#
  156. #ifdef __TURBOC__
  157. #define HUGE huge
  158. #else
  159. #define HUGE
  160. #endif
  161. @^system dependencies@>
  162. @z
  163. ------------------------------------------------------------------------------
  164. PORTABILITY, SYSTEM DEPENDENCIES, TRANSLATION
  165. @x l.35
  166. @ @<Include files@>=
  167. #include <stdio.h>
  168. @y
  169. @ Version~2.1 of the {\mc AMIGA} operating system introduced localization
  170. of programs and applications by means of ``language catalogs'' that contain
  171. replacement strings for terminal texts produced by suitably prepared programs.
  172. The complete \.{CWEB} system has been modified to accommodate this great idea
  173. and so the \.{cweb.h} header file with the original English strings is
  174. included in this section.  Other systems than the {\mc AMIGA} will have to do
  175. the language conversion by different means, so a little bit of care is to be
  176. taken with what follows.
  177. @^system dependencies@>
  178.  
  179. @f type int /* Aus \.{type} wird der Pseudotyp \&{type} */
  180. @#
  181. @d alloc_object(object,size,@!type)
  182.    if(!(object = (type *)calloc(size,sizeof(type))))
  183.       fatal("",get_string(MSG_FATAL_CO85));
  184.  
  185. @<Include files@>=
  186. #include <stdio.h>
  187. @#
  188. #ifdef __TURBOC__
  189. #include <io.h>
  190. #endif
  191. @#
  192. #ifndef _AMIGA /* non-{\mc AMIGA} systems don't know about \.{<exec/types.h>} */
  193. typedef long int LONG; /* excerpt from \.{<exec/types.h>} */
  194. typedef char * STRPTR; /* ditto, but \UNIX/ says it's signed. */
  195. #define EXEC_TYPES_H 1 /* don't include \.{<exec/types.h>} in \.{"cweb.h"} */
  196. #endif
  197. @#
  198. #ifdef STRINGARRAY
  199. #undef STRINGARRAY /* don't include the string array |AppStrings| again */
  200. #endif
  201. #define get_string(n) AppStrings[n].as_Str
  202. @#
  203. #include "cweb.h"
  204. @#
  205. struct AppString
  206. {
  207.    LONG   as_ID;
  208.    STRPTR as_Str;
  209. };
  210. @#
  211. extern struct AppString AppStrings[];
  212. @z
  213. ------------------------------------------------------------------------------
  214. MEMORY ALLOCATION
  215. @x l.58
  216. char section_text[longest_name+1]; /* name being sought for */
  217. char *section_text_end = section_text+longest_name; /* end of |section_text| */
  218. @y
  219. char *section_text; /* name being sought for */
  220. char *section_text_end; /* end of |section_text| */
  221. @z
  222. ------------------------------------------------------------------------------
  223. MEMORY ALLOCATION
  224. @x l.73
  225. extern char buffer[]; /* where each line of input goes */
  226. @y
  227. extern char *buffer; /* where each line of input goes */
  228. @z
  229. ------------------------------------------------------------------------------
  230. ANSI
  231. @x l.79
  232. @d length(c) (c+1)->byte_start-(c)->byte_start /* the length of a name */
  233. @y
  234. @d length(c) (size_t)((c+1)->byte_start-(c)->byte_start) /* the length of a name */
  235. @z
  236. ------------------------------------------------------------------------------
  237. PORTABILITY, SYSTEM DEPENDENCIES, MEMORY ALLOCATION
  238. @x l.88
  239. typedef struct name_info {
  240.   char *byte_start; /* beginning of the name in |byte_mem| */
  241.   struct name_info *link;
  242.   union {
  243.     struct name_info *Rlink; /* right link in binary search tree for section
  244.       names */
  245.     char Ilk; /* used by identifiers in \.{CWEAVE} only */
  246.   } dummy;
  247.   char *equiv_or_xref; /* info corresponding to names */
  248. } name_info; /* contains information about an identifier or section name */
  249. typedef name_info *name_pointer; /* pointer into array of \&{name\_info}s */
  250. typedef name_pointer *hash_pointer;
  251. extern char byte_mem[]; /* characters of names */
  252. extern char *byte_mem_end; /* end of |byte_mem| */
  253. extern name_info name_dir[]; /* information about names */
  254. extern name_pointer name_dir_end; /* end of |name_dir| */
  255. extern name_pointer name_ptr; /* first unused position in |byte_start| */
  256. extern char *byte_ptr; /* first unused position in |byte_mem| */
  257. @y
  258. typedef struct name_info {
  259.   char HUGE *byte_start; /* beginning of the name in |byte_mem| */
  260.   struct name_info HUGE *link;
  261.   union {
  262.     struct name_info HUGE *Rlink; /* right link in binary search tree for section
  263.       names */  
  264.     char Ilk; /* used by identifiers in \.{WEAVE} only */
  265.   } dummy;
  266.   void HUGE *equiv_or_xref; /* info corresponding to names */
  267. } name_info; /* contains information about an identifier or section name */
  268. typedef name_info HUGE *name_pointer; /* pointer into array of |name_info|s */
  269. typedef name_pointer *hash_pointer;
  270. extern char HUGE *byte_mem; /* characters of names */
  271. extern name_info HUGE *name_dir; /* information about names */
  272. extern char HUGE *byte_mem_end; /* end of |byte_mem| */
  273. extern name_pointer name_dir_end; /* end of |name_dir| */
  274. extern name_pointer name_ptr; /* first unused position in |byte_start| */
  275. extern char HUGE *byte_ptr; /* first unused position in |byte_mem| */
  276. #ifdef __TURBOC__
  277. void far *allocsafe(unsigned long nunits,unsigned long unitsz);
  278. #endif
  279. @^system dependencies@>
  280. @z
  281. ------------------------------------------------------------------------------
  282. MEMORY ALLOCATION
  283. @x l.106
  284. extern name_pointer hash[]; /* heads of hash lists */
  285. @y
  286. extern name_pointer *hash; /* heads of hash lists */
  287. @z
  288. ------------------------------------------------------------------------------
  289. ANSI
  290. @x l.109
  291. extern name_pointer id_lookup(); /* looks up a string in the identifier table */
  292. extern name_pointer section_lookup(); /* finds section name */
  293. extern void print_section_name(), sprint_section_name();
  294. @y
  295. extern int names_match(name_pointer,char *,int,eight_bits);@/
  296. extern name_pointer id_lookup(char *,char *,char);
  297.    /* looks up a string in the identifier table */
  298. extern name_pointer prefix_lookup(char *,char *); /* finds section name given a prefix */
  299. extern name_pointer section_lookup(char *,char *,int);@/
  300. extern void init_node(name_pointer);@/
  301. extern void init_p(name_pointer,eight_bits);@/
  302. extern void print_prefix_name(name_pointer);@/
  303. extern void print_section_name(name_pointer);@/
  304. extern void sprint_section_name(char *,name_pointer);@/
  305. @z
  306. ------------------------------------------------------------------------------
  307. ANSI, TRANSLATION
  308. @x l.117
  309. @d fatal_message 3 /* |history| value when we had to stop prematurely */
  310. @d mark_harmless {if (history==spotless) history=harmless_message;}
  311. @d mark_error history=error_message
  312. @d confusion(s) fatal("! This can't happen: ",s)
  313.  
  314. @<Common...@>=
  315. extern history; /* indicates how bad this run was */
  316. extern err_print(); /* print error message and context */
  317. extern wrap_up(); /* indicate |history| and exit */
  318. extern void fatal(); /* issue error message and die */
  319. extern void overflow(); /* succumb because a table has overflowed */
  320. @y
  321. @d fatal_message 3 /* |history| value when we had to stop prematurely */
  322. @d mark_harmless {if (history==spotless) history=harmless_message;}
  323. @d mark_error history=error_message
  324. @d confusion(s) fatal(get_string(MSG_FATAL_CO66),s)
  325.  
  326. @<Common...@>=
  327. extern history; /* indicates how bad this run was */
  328. extern int wrap_up(void); /* indicate |history| and exit */
  329. extern void err_print(char *); /* prints error message and context */
  330. extern void fatal(char *,char *); /* issue error message and die */
  331. extern void overflow(char *); /* succumb because a table has overflowed */
  332. @z
  333. ------------------------------------------------------------------------------
  334. PORTABILITY
  335. @x l.131
  336. @d max_file_name_length 60
  337. @y
  338. @d max_file_name_length 256
  339. @z
  340. ------------------------------------------------------------------------------
  341. MEMORY ALLOCATION
  342. @x l.139
  343. extern FILE *file[]; /* stack of non-change files */
  344. extern FILE *change_file; /* change file */
  345. extern char C_file_name[]; /* name of |C_file| */
  346. extern char tex_file_name[]; /* name of |tex_file| */
  347. extern char idx_file_name[]; /* name of |idx_file| */
  348. extern char scn_file_name[]; /* name of |scn_file| */
  349. extern char file_name[][max_file_name_length];
  350.   /* stack of non-change file names */
  351. extern char change_file_name[]; /* name of change file */
  352. extern line[]; /* number of current line in the stacked files */
  353. @y
  354. extern FILE **file; /* stack of non-change files */
  355. extern FILE *change_file; /* change file */
  356. extern char *C_file_name; /* name of |C_file| */
  357. extern char *tex_file_name; /* name of |tex_file| */
  358. extern char *idx_file_name; /* name of |idx_file| */
  359. extern char *scn_file_name; /* name of |scn_file| */
  360. extern char **file_name; /* stack of non-change file names */
  361. extern char *change_file_name; /* name of change file */
  362. extern int *line; /* number of current line in the stacked files */
  363. @z
  364. ------------------------------------------------------------------------------
  365. ANSI
  366. @x l.153
  367. extern reset_input(); /* initialize to read the web file and change file */
  368. extern get_line(); /* inputs the next line */
  369. extern check_complete(); /* checks that all changes were picked up */
  370. @y
  371. extern boolean get_line(void); /* inputs the next line */
  372. extern void check_complete(void); /* checks that all changes were picked up */
  373. extern void reset_input(void); /* initialize to read the web file and change file */
  374. @z
  375. ------------------------------------------------------------------------------
  376. MEMORY ALLOCATION
  377. @x l.161
  378. extern boolean changed_section[]; /* is the section changed? */
  379. @y
  380. extern boolean *changed_section; /* is the section changed? */
  381. @z
  382. ------------------------------------------------------------------------------
  383. PORTABILITY
  384. @x l.165
  385. @ Code related to command line arguments:
  386. @d show_banner flags['b'] /* should the banner line be printed? */
  387. @d show_progress flags['p'] /* should progress reports be printed? */
  388. @d show_happiness flags['h'] /* should lack of errors be announced? */
  389. @y
  390. @ Code related to command line arguments:
  391. @d show_banner flags['b'] /* should the banner line be printed? */
  392. @d show_happiness flags['h'] /* should lack of errors be announced? */
  393. @d show_progress flags['p'] /* should progress reports be printed? */
  394. @d use_amiga_keywords flags['a'] /* should {\mc AMIGA/SAS C} keywords be used? */
  395. @d use_german_macros flags['g'] /* should the output be German? */
  396. @d indent_param_decl flags['i'] /* should formal parameter declarations be indented? */
  397. @d order_decl_stmt flags['o'] /* should declarations and statements be separated? */
  398. @d send_error_messages flags['m'] /* should {\mc AREXX} communication be used? */
  399. @z
  400. ------------------------------------------------------------------------------
  401. @x l.173
  402. extern boolean flags[]; /* an option for each 7-bit code */
  403. @y
  404. extern boolean flags[]; /* an option for each 8-bit code */
  405. @z
  406. ------------------------------------------------------------------------------
  407. ANSI
  408. @x l.192
  409. extern void common_init();
  410. @y
  411. extern void common_init(void);
  412. extern void print_stats(void);
  413. @z
  414. ------------------------------------------------------------------------------
  415.